package com.qf.flash.mvp.presenter;

import com.qf.dblib.dao.impl.UserMgr;
import com.qf.flash.http.HttpManager;
import com.qf.flash.model.CapacityBean;
import com.qf.flash.mvp.contract.CapacityContract;
import com.qf.flashlib.base.BasePresenter;
import com.qf.flashlib.base.BaseResponse;
import com.qf.flashlib.base.BaseSubscriber;
import com.qf.flashlib.util.RxUtils;

import java.util.List;

public class CapacityPresenter extends BasePresenter<CapacityContract.View> implements CapacityContract.Presenter {

    @Override
    public void getCapacityData( String type, int pageNo, int pageSize) {
        String uid = UserMgr.getInstance().getLoginUser().getUid();
        addSubscription(HttpManager.getInstance().getGsonHttpApi()
                .GET_CAPACITY_LIST(uid,type, pageNo, pageSize)
                .compose(RxUtils.handleBaseResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<BaseResponse<List<CapacityBean>>>(mRootView,true) {
                    @Override
                    public void onSuccess(BaseResponse<List<CapacityBean>> listResponse) {
                        mRootView.setCapacityData(listResponse.getData(),listResponse.getTotalPage());
                    }
                })
        );
    }


}
